import { reportInter } from "../../data/Interface"
// 举报动态
const addmainreport = (dynamic_id, user_id, report_context) => {
    return (dispatch) => {
        let url = `${reportInter}`
        fetch(url, {
            method: 'POST',
            mode: 'cors',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                user_id: `${user_id}`,
                dynamic_id: `${dynamic_id}`,
                report_context: `${report_context}`
            })
        }).then((res) => {
            return res.json()
        }).then((res) => {
            dispatch({
                type: 'ADD_REPO',
                value: res.data
            })
        })
    }
}

// 参数 动态id，举报者id，举报内容，被举报评论id
const addDyCommReport = (user_id, report_context, comment_id) => {
    return (dispatch) => {
        let url = `${reportInter}`
        fetch(url, {
            method: 'POST',
            mode: 'cors',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                user_id: `${user_id}`,
                report_context: `${report_context}`,
                comment_id: `${comment_id}`,
            })
        }).then((res) => {
            return res.json()
        }).then((res) => {
            console.log(res.data)
            dispatch({
                type: 'ADD_DY_REPO',
                value: res.data
            })
        })
    }
}
// 举报商品 举报人 举报内容 举报的商品
const addDyshopReport = (user_id, report_context, commodity_id) => {
    console.log(user_id, report_context, commodity_id)
    return (dispatch) => {
        let url = `${reportInter}`
        fetch(url, {
            method: 'POST',
            mode: 'cors',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                user_id: `${user_id}`,
                report_context: `${report_context}`,
                commodity_id: `${commodity_id}`,
            })
        }).then((res) => {
            return res.json()
        }).then((res) => {
            console.log(res.data)
            dispatch({
                type: 'ADD_SP_REPO',
                value: res.data
            })
        })
    }
}

// 举报商家


const addDybusReport = (user_id, report_context, business_id2) => {
    console.log(user_id, report_context, business_id2)
    return (dispatch) => {
        let url = `${reportInter}`
        fetch(url, {
            method: 'POST',
            mode: 'cors',
            headers: {
                'Content-Type': 'application/json'
            },
            body: JSON.stringify({
                user_id: `${user_id}`,
                report_context: `${report_context}`,
                business_id2: `${business_id2}`,
            })
        }).then((res) => {
            return res.json()
        }).then((res) => {
            console.log(res.data)
            dispatch({
                type: 'ADD_BUS_REPO',
                value: res.data
            })
        })
    }
}
export { addmainreport, addDyCommReport, addDybusReport, addDyshopReport }